package io;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 缓冲流
 * java.io.BufferedInputStream和BufferedOutputStream
 * 缓冲流是一对高级流，在流的连接中作用为加快读写效率。无论我们使用块读写
 * 还是单字节读写，缓冲流最终都会统一转换为块读写以保证读写效率。
 * @author Xiloer
 *
 */
public class CopyDemo2 {
	public static void main(String[] args) throws IOException {
		FileInputStream fis = new FileInputStream("唱歌的孩子.mp3");
		BufferedInputStream bis = new BufferedInputStream(fis);
		
		FileOutputStream fos = new FileOutputStream("唱歌的孩子_cp.mp3");
		BufferedOutputStream bos = new BufferedOutputStream(fos);
		
		int d = 0;
		long start = System.currentTimeMillis();
		while((d = bis.read())!=-1) {
			bos.write(d);
		}
		long end = System.currentTimeMillis();
		System.out.println("复制完毕!耗时:"+(end-start)+"ms");
		bis.close();
		bos.close();
	}
	
	
	
	
	
	
}





